<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <common-head></common-head>
    <hr>
    <common-head></common-head>
  </div>
  <script src="./vue.js"></script>
  <script>
    Vue.component('CommonHead', {
      template: `
        <div>
          <h1>我是头部组件</h1>
          {{ msg }}  
          <button @click="changeMsg"> 改变msg </button>
        </div>
      `,
      data(){
        return {
          msg: '你好组件'
        }
      },
      methods: {
        changeMsg(){
          this.msg = '你好世界';
        }
      },
      watch:{
        msg(){
          console.log('msg改变了')
        }
      }
    })
    const vm = new Vue({
      el: '#app'
    })
  </script>
</body>
</html>